package com.house.business.controller;

import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.house.business.service.HousingResourcesInfoService;
import com.house.business.entity.HousingResourcesInfo;
import com.house.business.vo.HousingResourcesInfoVo;
import org.springframework.web.bind.annotation.RestController;
import com.house.framework.controller.BaseController;

/**
 * <p>
 * 房源表 前端控制器
 * </p>
 *
 * @since 2023-05-09
 */
@Slf4j
@RestController
@RequestMapping("/housingResourcesInfoController")
public class HousingResourcesInfoController extends BaseController {

    @Autowired
    private HousingResourcesInfoService housingResourcesInfoService;
    /**
    * 新增房源表
    * @param entity
    * t_housing_resources_info新增数据
    * @return 新增数据id
    */
    @ApiOperation(value = "房源表", notes = "新增房源表")
    @RequestMapping(value = "/addHousingResourcesInfo", method = RequestMethod.POST)
    public Object addHousingResourcesInfo(@RequestBody HousingResourcesInfo entity) {
        return housingResourcesInfoService.addHousingResourcesInfo(entity);
    }

    /**
    * 修改房源表
    * @param entity
    * t_housing_resources_info修改数据
    * @return 修改记录数
    */
    @ApiOperation(value = "房源表", notes = "修改房源表")
    @RequestMapping(value = "/updateHousingResourcesInfo", method = RequestMethod.POST)
    public Object updateHousingResourcesInfo(@RequestBody HousingResourcesInfo entity) {
        return housingResourcesInfoService.updateHousingResourcesInfo(entity);
    }

    /**
    * 取指定ID的房源表数据
    * @param id
    * t_housing_resources_info 主键ID
    * @return 返回实体对象
    * 返回指定id 房源表数据
    */
    @ApiOperation(value = "房源表", notes = "取房源表")
    @RequestMapping(value = "/getHousingResourcesInfoById", method = RequestMethod.GET)
    public HousingResourcesInfoVo getHousingResourcesInfoById(@RequestParam Long id) {
        return housingResourcesInfoService.getHousingResourcesInfoById(id);
    }

    /**
    * 房源表分页取数
    * @param entityVo
    * t_housing_resources_info 分页取数参数，pageIndex=页码；pageSize=每页记录数；
    * @return
    * 返回分页数据
    */
    @RequestMapping(value = "/getHousingResourcesInfoList", method = RequestMethod.POST)
    public IPage<HousingResourcesInfoVo> getHousingResourcesInfoList(@RequestBody HousingResourcesInfoVo entityVo){
        IPage<HousingResourcesInfoVo> page = housingResourcesInfoService.getHousingResourcesInfoList(entityVo);
        return page;
    }

    /**
    * 删除指定ID的房源表数据
    * @param id
    * t_housing_resources_info 主键ID
    */
    @ApiOperation(value = "房源表", notes = "删除房源表")
    @RequestMapping(value = "/deleteHousingResourcesInfoById/{id}", method = RequestMethod.GET)
    public void deleteHousingResourcesInfoById(@PathVariable("id") Long id) {
         housingResourcesInfoService.deleteHousingResourcesInfoById(id);
    }

    /**
    * 批量删除指定ID的房源表数据
    * @param ids
    * t_housing_resources_info 主键ID
    */
    @ApiOperation(value = "房源表", notes = "批量删除房源表")
    @RequestMapping(value = "/batchDelete", method = RequestMethod.POST)
    public void batchDelete(@RequestParam Long[] ids) {
        housingResourcesInfoService.batchDelete(ids);
    }

}
